package com.s63.springboot3.controller;

import com.s63.springboot3.config.CacheManager;
import com.s63.springboot3.entity.AjaxResult;
import com.s63.springboot3.entity.Role;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/roles")
public class RoleController {

    @GetMapping
    public AjaxResult getAll() {
        // 从缓存中获取数据，如果为空，则查询数据库并放入缓存
        return AjaxResult.ok((List<Role>) CacheManager.get("roleList"));
    }
}
